#include "myqgsmaptoolpan.h"

#include "textqgsmapcanvasitem.h"

#include <qgsmapcanvasitem.h>
#include <qgsmapmouseevent.h>


MyQgsMapToolPan::MyQgsMapToolPan(QgsMapCanvas *canvas)
    :QgsMapToolPan(canvas)
{
   setCursor(Qt::ClosedHandCursor);
}

void MyQgsMapToolPan::canvasPressEvent(QgsMapMouseEvent *event)
{
    // if (event->buttons() & Qt::LeftButton) {
    //     QgsMapCanvas *canvas = this->canvas();
    //     canvas->mouse
    // }
    mLastMousePos = event->pos();

    setCursor(Qt::ClosedHandCursor);
    mDrag = true;

}

// void MyQgsMapToolPan::canvasMoveEvent(QgsMapMouseEvent *e)
// {

//     setCursor(Qt::ArrowCursor);
//     if ((e->buttons() & Qt::LeftButton) && mDrag) {
//          qDebug() << "222222";
//         QgsPointXY center = canvas()->center();
//         double dx = e->pos().x() - mLastMousePos.x();
//         double dy = e->pos().y() - mLastMousePos.y();
//         canvas()->centerOn(center.x() - dx, center.y() - dy);
//         mLastMousePos = e->pos();

//     }
// }

void MyQgsMapToolPan::canvasReleaseEvent(QgsMapMouseEvent *e)
{
    mDrag =false;
}
